<?php

/**
 * Store form base class.
 *
 * @package    form
 * @subpackage store
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseStoreForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'url'         => new sfWidgetFormInput(),
      'name'        => new sfWidgetFormInput(),
      'owner'       => new sfWidgetFormInput(),
      'address'     => new sfWidgetFormTextarea(),
      'phone'       => new sfWidgetFormInput(),
      'website'     => new sfWidgetFormInput(),
      'email'       => new sfWidgetFormInput(),
      'logo'        => new sfWidgetFormInput(),
      'description' => new sfWidgetFormTextarea(),
      'is_active'   => new sfWidgetFormInputCheckbox(),
      'is_main'     => new sfWidgetFormInputCheckbox(),
      'created_at'  => new sfWidgetFormDateTime(),
      'updated_at'  => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => 'Store', 'column' => 'id', 'required' => false)),
      'url'         => new sfValidatorString(array('max_length' => 255)),
      'name'        => new sfValidatorString(array('max_length' => 255)),
      'owner'       => new sfValidatorString(array('max_length' => 255)),
      'address'     => new sfValidatorString(array('max_length' => 1000, 'required' => false)),
      'phone'       => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'website'     => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'email'       => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'logo'        => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'description' => new sfValidatorString(array('max_length' => 2000, 'required' => false)),
      'is_active'   => new sfValidatorBoolean(),
      'is_main'     => new sfValidatorBoolean(),
      'created_at'  => new sfValidatorDateTime(array('required' => false)),
      'updated_at'  => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Store', 'column' => array('url'))),
        new sfValidatorDoctrineUnique(array('model' => 'Store', 'column' => array('name'))),
      ))
    );

    $this->widgetSchema->setNameFormat('store[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Store';
  }

}
